package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Features;
import com.ruoyi.system.service.IFeaturesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特色信息Controller
 * 
 * @author ruoyi
 * @date 2024-01-05
 */
@RestController
@RequestMapping("/system/features")
public class FeaturesController extends BaseController
{
    @Autowired
    private IFeaturesService featuresService;

    /**
     * 查询特色信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:features:list')")
    @GetMapping("/list")
    public TableDataInfo list(Features features)
    {
        startPage();
        List<Features> list = featuresService.selectFeaturesList(features);
        return getDataTable(list);
    }

    /**
     * 导出特色信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:features:export')")
    @Log(title = "特色信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Features features)
    {
        List<Features> list = featuresService.selectFeaturesList(features);
        ExcelUtil<Features> util = new ExcelUtil<Features>(Features.class);
        util.exportExcel(response, list, "特色信息数据");
    }

    /**
     * 获取特色信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:features:query')")
    @GetMapping(value = "/{featureId}")
    public AjaxResult getInfo(@PathVariable("featureId") Long featureId)
    {
        return success(featuresService.selectFeaturesByFeatureId(featureId));
    }

    /**
     * 新增特色信息
     */
    @PreAuthorize("@ss.hasPermi('system:features:add')")
    @Log(title = "特色信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Features features)
    {
        return toAjax(featuresService.insertFeatures(features));
    }

    /**
     * 修改特色信息
     */
    @PreAuthorize("@ss.hasPermi('system:features:edit')")
    @Log(title = "特色信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Features features)
    {
        return toAjax(featuresService.updateFeatures(features));
    }

    /**
     * 删除特色信息
     */
    @PreAuthorize("@ss.hasPermi('system:features:remove')")
    @Log(title = "特色信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{featureIds}")
    public AjaxResult remove(@PathVariable Long[] featureIds)
    {
        return toAjax(featuresService.deleteFeaturesByFeatureIds(featureIds));
    }
}
